/**
* @desc:  消息通知
* @author qiankui
* @date qiankui 2023-9-8 14:42:42
*/
<template>
    <el-dialog :close-on-click-modal="false" :visible="notifyFlag" class="zdy-dialog" width="600px"
               :title="$t('Notify')" :before-close="handleCloseDialog">
        <el-form :model="form" label-position="left" class="pop-form-box" ref="ruleForm">

            <el-row :gutter="20">
                <el-col :span="24">
                    <!--消息通知-->
                    <el-form-item :label="$t('Notify')" prop="uploadUrl">
                        <el-switch  :active-value="1"
                                    :inactive-value="0" v-model="form.popupEnable"></el-switch>
                    </el-form-item>
                </el-col>
            </el-row>

            <div class="footBtnBox">
                <el-button size="small" type="handle" @click="handleCloseDialog">{{this.i18n.t('Cancel')}}</el-button>
                <el-button size="small" type="primary" @click="submitForm">{{this.i18n.t('save')}}</el-button>
            </div>
        </el-form>
    </el-dialog>
</template>

<script>
    import { cachestroeSet, cachestroeGet } from "@/api/login.js";
    export default {
        name: "notify",
        props: {
            notifyFlag: {
                type: Boolean,
                default: false
            }
        },
        data() {
            return {
                keyName:'popupEnable',
                form:{
                    popupEnable:0
                }
            }
        },
        mounted() {
            this.cachestroeGet()
        },
        methods: {
            cachestroeSet(val) {
                cachestroeSet({ key: this.keyName, value: val }).then((res) => {
                    if (res.code == 200) {
                        // 保存成功
                        this.W.$tips("success", this.i18n.t('Successfully saved'));
                        this.handleCloseDialog()
                    }
                });
            },
            cachestroeGet() {
                cachestroeGet(this.keyName).then((res) => {
                    if (res.code == 200) {
                        this.form.popupEnable = res.data;
                    }
                });
            },

            /**
             * @description  关闭弹窗事件
             * @return not
             * @author xiongyi 2022-06-29 16:48:08
             **/
            handleCloseDialog() {
                this.$emit('update:notifyFlag', false);
            },
            /**
             * @description  保存新增活修改数据
             * @param  not
             * @return not
             * @author xiongyi 2022-07-06 10:50:18
             **/
            submitForm() {
                this.cachestroeSet(this.form.popupEnable);
            }
        }
    }
</script>

<style scoped>

</style>